<?php

namespace iBrand\Component\Discount\Checkers;

use iBrand\Component\Discount\Contracts\DiscountContract;
use iBrand\Component\Discount\Contracts\DiscountSubjectContract;
use iBrand\Component\Discount\Contracts\RuleCheckerContract;
use iBrand\Component\Discount\Contracts\DiscountItemContract;

class ContainsSeasonRuleChecker implements RuleCheckerContract
{
	const TYPE = 'contains_season';

	public function isEligible(DiscountSubjectContract $subject, array $configuration, DiscountContract $discount)
	{
		if ($subject->channel != 'shop') {
			return false;
		}

		if (!isset($configuration['season_id']) || !$configuration['season_id']) {
			return false;
		}

		if (empty($season_id) || !in_array($subject->season_id, $configuration['season_id'])) {
			return false;
		}

		return true;
	}

	public function isEligibleByItem(DiscountItemContract $item, array $configuration)
	{
		if (in_array($item->season_id, $configuration['season_id'])) {
			return true;
		}

		return false;
	}
}